package oj;

//回文链表
public class Num027 {
    public boolean isPalindrome(ListNode head) {
        //
        if(head == null || head.next == null){
            return true;
        }
        int[] arr = new int[900];
        ListNode node = head;
        int i = 0;
        while (node != null){
            arr[i++] = node.val;
            node = node.next;
        }

        int start = 0;
        int end = i - 1;
        while (start < end){
            if (arr[start] != arr[end]){
                return false;
            }
            start++;
            end--;
        }
        return true;
    }
}
